﻿//using System;
//using System.Collections.Generic;
//using System.Globalization;
//using System.Linq;
//using System.Text;
//using Brouteforce.GameObjects;
//using Brouteforce.gameObjs;
//using Brouteforce.gameObjs.gamePiece;
//using Brouteforce.gameobjs;
//using Brouteforce.utilities;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Input;

//namespace Brouteforce.managers {
//    /// <summary>
//    /// Represents all the operations the user can make the game pieces do
//    /// </summary>
//    public enum State {
//        Selection,
//        Walking,
//        Firing,
//        GeneratingNewGamePiece,
//        None
//    }

//    public class PlayersManager {

//        public static PlayersManager Instance = new PlayersManager();
//        public const int NumOfPlayers = 2;
//        public static Player[] Players;
//        public static int SelectedPlayer;
//        public string ComputerName = "Computer";
//        public const int TurnDelta = 1000;
//        public Tile PressedTile;
//        public static bool TurnChanged;
//        public static double TurnTime;
//        public static String TurnString;

//        public PlayersManager() {
//        }

//        private void DrawChangeTurn() {
//            TurnChanged = true;
//            ChangeTurn();
//            TurnTime = BFGame.CurrentTime.TotalGameTime.TotalMilliseconds;
//            TurnString = "Player " + SelectedPlayer + " Turn";
//        }

//        /// <summary>
//        /// This method is called when the player's turn has ended 
//        /// </summary>
//        public void ChangeTurn() {
//            SelectedPlayer++;
//            SelectedPlayer = SelectedPlayer % NumOfPlayers;
//            Players[SelectedPlayer].InitTurn();
//        }

//        public void Update() {
//            UpdatePlayerStates();
//            Players[SelectedPlayer].Update();
//        }

//        private void UpdatePlayerStates() {
//            if (GameManager.IsNewGameStarted) {
//                Players = new Player[2];
//                Players[0] = new Player(0, WorldManager.InitialGameTowers[0], 100 , Color.Red);
//                Players[1] = new Player(1, WorldManager.InitialGameTowers[1], 100 , Color.Blue);
//            }

//            foreach (var key in InputManager.CurrentClickedKeys) {
//                switch (key) {
//                    case Keys.G:
//                        InputState = State.GeneratingNewGamePiece;
//                        break;
//                    case Keys.F:
//                        InputState = State.Firing;
//                        break;
//                    case Keys.W:
//                        InputState = State.Walking;
//                        break;
//                    case Keys.S:
//                        InputState = State.Selection;
//                        break;
//                    case Keys.Escape:
//                        InputState = State.Selection;
//                        break;
//                    case Keys.Space:
//                        DrawChangeTurn();
//                        break;
//                }
//            }

//        }

//        public void CurrentPlayerResources(out int life, out int light, out int speed, out int power) {
//            if (Players[SelectedPlayer].CurrentCharacter == null) {
//                life = light = speed = power = -1;
//                return;
//            }

//            life = Players[SelectedPlayer].CurrentCharacter.Life;
//            light = Players[SelectedPlayer].CurrentCharacter.Light;
//            speed = Players[SelectedPlayer].CurrentCharacter.NumberOfMovesLeft;
//            power = Players[SelectedPlayer].CurrentCharacter.Power;
//        }


//        public static void DecreaseLife(GamePiece gamePiece, int power) {
//            gamePiece.DecreaseLife(power);
//            if (gamePiece.Life <= 0) {
//                WorldManager.RemoveGamePiece(gamePiece);
//                Players[gamePiece.BelongsToPlayer].RemoveGamePiece(gamePiece);
//            }
//        }

//        #region Output

//        public static Player GetCurrentPlayer()
//        {
//            return Players[SelectedPlayer];
//        }

//        public static GamePiece SelectedGamePiece { get{
//            return Players == null ? null : Players[SelectedPlayer].CurrentCharacter;
//        }
//        }
//        public static State InputState = State.Selection;
//        #endregion

//        public Color GetCurrentPlayerColor()
//        {
//            return Players[SelectedPlayer].PlayerColor;
//        }

//        public static int GetResources(string p) {
//            if (p.Equals("speed"))
//                return Players[SelectedPlayer].SpeedResource;
//            if (p.Equals("life"))
//                return Players[SelectedPlayer].LifeResource;
//            if (p.Equals("light"))
//                return Players[SelectedPlayer].LightResource;
//            return p.Equals("power") ? Players[SelectedPlayer].PowerResource : 0;
//        }

//        public static void Draw()
//        {
//            if (PlayersManager.TurnChanged) {
//                if (BFGame.CurrentTime.TotalGameTime.TotalMilliseconds - PlayersManager.TurnTime <= PlayersManager.TurnDelta) {
//                    BFGame.SpriteBatch.DrawString(BFGame.MessageFont, PlayersManager.TurnString, new Vector2(200, 150), Color.Green);
//                } else {
//                    PlayersManager.TurnTime = BFGame.CurrentTime.ElapsedGameTime.TotalMilliseconds;
//                    PlayersManager.TurnChanged = false;
//                }
//            }

//        }


//        public int GetCurrentPlayerName()
//        {
//            return Players[SelectedPlayer].PlayerId;
//        }

//        public int HowManyTowersDoesThePlayerHave()
//        {
//            if(Players!=null)
//                return Players[SelectedPlayer].towers.Count();
//            else
//                return -1;
//        }
//    }
//}